

import React from 'react'
import store from '../../store'
//引入actions
import { incrementAction, decrementAction,waitcrementAction } from '../../store/actions/countActions'
import { INCREMENTCOUNT } from '../../store/constant/countConst'
export default function Count() {
  //通过 store.getState()的方法获取到store中的值并解构出来
  const { count } = store.getState().count
  const {movielist} = store.getState().movie
  //累加
  const changeNumAdd = () => {
    //通过 store.dispatch()向store发送消息
    store.dispatch(incrementAction())
  }
  //累减
  const changeNumSub = () => {
    store.dispatch(decrementAction())
  }
  //延时累加
  const waitNumAdd = () => {
    store.dispatch(waitcrementAction(1))
  }
  return (
    <div>
      <h1>Count</h1>
      <p>数字{count}</p>
      <p>电影数量{movielist.length}</p>
      <button onClick={changeNumAdd}>累加</button>
      <button onClick={changeNumSub}>累减</button>
      <button onClick={waitNumAdd}>2s后加</button>
    </div>
  )
}
